﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using TowerDefence.Entities.States;

namespace TowerDefence
{
    public class CollisionCircle : State
    {
        private float radius;

        public float Radius 
        {
            get { return this.radius; }
            set
            {
                if (value <= 0) throw new ArgumentException("Can't create a circle with zero or negative radius");
                this.radius = value;
            } 
        }
        public Vector2 Position { get; set; }
    }

    public static class Collision
    {
        /// <summary>
        /// Tests for collision between two circles
        /// </summary>
        /// <returns>True if they intersect</returns>
        public static bool Collides(CollisionCircle _a, CollisionCircle _b)
        {
            var difference = _a.Position - _b.Position;
            return difference.Length() < _a.Radius || difference.Length() < _b.Radius;
        }
    }
}
